﻿using MathNet.Numerics.Distributions;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SystemLYH.Domain.Dto;
using SystemLYH.API.Application.Command.ProcurementAndStorageCommand;

namespace SystemLYH.API.Controllers
{
    /// <summary>
    /// 采购入库
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProcurementAndStorageController : ControllerBase
    {
        /// <summary>
        /// 日志
        /// </summary>
        ILogger<ProcurementAndStorageController> logger;
        /// <summary>
        /// 中介者
        /// </summary>
        IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="logger">日志</param>
        /// <param name="mediator">中介者</param>
        public ProcurementAndStorageController(ILogger<ProcurementAndStorageController> logger, IMediator mediator)
        {
            this.logger = logger;
            this.mediator = mediator;
        }
        /// <summary>
        /// 采购入库显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<PageDTO<StorageProcuredrequestDTO>>> ProcurementAndStorageShow([FromQuery]ProcurementAndStorageShowCommand request)
        {
            ApiResult<PageDTO<StorageProcuredrequestDTO>> result = new ApiResult<PageDTO<StorageProcuredrequestDTO>>();
            try
            {
                result.Data = await mediator.Send(request);
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Code = -1;
                throw;
            }
            return result;
        }



    }
}
